//
//  BKRightCollectionViewCell.m
//  bestkeep
//
//  Created by utouu_mhm on 16/11/7.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "BKRightCollectionViewCell.h"
#import "masonry.h"
#define UIBackColor(r,g,b) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:1]
#define FontSize [UIFont systemFontOfSize:13]
#define IPHONE_WIDTH [UIScreen mainScreen].bounds.size.width
//表格的宽度
#define tableWidthSize 210.0f/750.0f*IPHONE_WIDTH

@interface BKRightCollectionViewCell ()

@property (nonatomic, strong) UIImageView *cellImageView;

@end

@implementation BKRightCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        [self createUI];
    }
    return self;
}

-(void)createUI {
    
    __weak typeof (self) weakself = self;
    
    self.cellImageView = [[UIImageView alloc] init];
    [self.cellImageView setContentMode:UIViewContentModeScaleAspectFit];
    [self.contentView addSubview:self.cellImageView];
    
    self.nameLabel = [[UILabel alloc]init];
    self.nameLabel.font = [UIFont systemFontOfSize:12.0];
    self.nameLabel.textColor = RGBACOLOR(102, 102, 102, 1);
    self.nameLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.nameLabel];
    
    [self.cellImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
//        make.centerX.mas_equalTo(self.contentView.mas_centerX);
        make.left.mas_equalTo(self.contentView.mas_left).mas_offset(4);
        make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-4);
        make.top.mas_equalTo(self.contentView.mas_top);
        make.height.mas_equalTo(self.cellImageView.mas_width).multipliedBy(1);

    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakself.contentView.mas_left);
        make.centerX.mas_equalTo(weakself.contentView.mas_centerX);
        make.top.mas_equalTo(weakself.cellImageView.mas_bottom).mas_offset(4);
    }];
}

-(void)setRightModel:(ThirdChildrenList *)rightModel{
     _rightModel = rightModel;
    self.nameLabel.text = _rightModel.name;
    [self.cellImageView load:_rightModel.iconUrl placeholderImage:[UIImage imageNamed:@"AccountBitMap"]];
}

+ (CGSize)collectionCellSize{
    
    return CGSizeMake(([UIScreen mainScreen].bounds.size.width-tableWidthSize-10.0f)/3,([UIScreen mainScreen].bounds.size.width-tableWidthSize-9.0f)/3*70.0f/174.0f+([UIScreen mainScreen].bounds.size.width-tableWidthSize-9.0f)/3);
}

@end
